import Vue from 'vue'
import Router from 'vue-router'
import Home from '../components/Home'
import Login from "../components/Login";
import Register from "../components/Register";
import Course from "../components/Course";
import Detail from "../components/Detail";
import Player from "../components/Player";
import Cart from "../components/Cart";
import Order from "../components/Order";
import Success from "../components/Success";
import UserOrder from "../components/UserOrder";
import User from "../components/User";

Vue.use(Router);

export default new Router({
  mode: 'history',
  routes: [
    {
      path: '/',
      redirect: {name:'Home'},
    },
    {
      name: 'Home',
      path: '/home',
      component: Home
    },
    {
      name: 'Login',
      path: '/login',
      component: Login
    },
    {
      name: 'Register',
      path: '/register',
      component: Register,
    },
      {
      name: 'Course',
      path: '/course',
      component: Course,
    },
    {
      name: "Detail",
      path:"/detail",
      component: Detail,
    },
    {
      name: "Player",
      path: "/player",
      component: Player,
    },
    {
      name: "Cart",
      path: "/cart",
      component: Cart,
    },
    {
      name: "Order",
      path: "/orders/:order",  // 地址栏的命名绑定参数, 在组件中可以通过 this.$router.param.order可以获取数据
      component: Order,
    },
    {
      name: "Success",
      path: "/success",  // 地址栏的命名绑定参数, 在组件中可以通过 this.$router.param.order可以获取数据
      component: Success,
    },
    {
      name:"User",
      path:"/my",
      component: User,
      // children:[  // 设置子路由,在父级路由对应的组件中如果存在父子公用部分页面,可以使用router-view来实现子路由
      //   {
      //     name:"UserOrder",
      //     path:"/order",
      //     component: UserOrder,
      //   }
      // ]
    },
    {
      name: "UserOrder",
      path: "/my/order",
      component: UserOrder,
    }

  ]
})
